package cn.example.demo.modules.house.entity;

import cn.example.demo.common.model.tree.factory.AbstractTreeNode;
import cn.example.demo.common.tools.obj.reflect.FieldAlias;
import cn.example.demo.common.tools.obj.reflect.Immutable;
import com.baomidou.mybatisplus.annotation.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.FieldNameConstants;

import java.io.Serializable;
import java.util.List;

/**
 * 描述：【地区】实体类
 */
@FieldNameConstants
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Region implements AbstractTreeNode<Region>, Serializable {
    private static final long serialVersionUID = 1L;

    @Immutable
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    @FieldAlias("ID")
    private String id;

    @FieldAlias("父级地区")
    private String parentId;

    @FieldAlias("名称")
    private String name;

    @FieldAlias("备注")
    private String remark;

    @FieldAlias("是否中高风险地区")
    private String isHighRisk;

    @TableField(exist = false)
    private List<Region> children;

    @TableField(exist = false)
    private List<Region> parents;

    @Override
    public String getNodeId() {
        return this.id.toString();
    }

    @Override
    public String getNodeParentId() {
        return this.parentId.toString();
    }

    @Override
    public void setChildrenNodes(List<Region> childrenNodes) {
        this.children = childrenNodes;
    }

    @Override
    public void setParentsNodes(List<Region> parentsNodes) {
        this.parents = parentsNodes;
    }
}
